package cn.doitedu.day05

import scala.io.Source

object T01_IteratorDemo {

  def main(args: Array[String]): Unit = {

    val source = Source.fromFile("data/words.txt")

    val lines: Iterator[String] = source.getLines()

    val filtered: Iterator[String] = lines.filter(line => {
      !line.startsWith("4")
    })

    val upper: Iterator[String] = filtered.map(line => {
      line.toUpperCase()
    })

    while (upper.hasNext) {
      val res = upper.next()
      println(res)
    }

    source.close()
  }
}
